//
//  FindPassworldVC.m
//  FindJob
//
//  Created by 233 on 16/2/29.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "FindPassworldVC.h"
#import "WaitAlertView.h"
#import "AlertView.h"

static NSString *const kReplacePassworldVC = @"ReplacePassworldVC";
@interface FindPassworldVC ()

@end

@implementation FindPassworldVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (IBAction)commitBtn:(UIButton *)sender {
    
    if ( [self judgeEmailTextFeildIsValid:self.accountTextField]) {
        WaitAlertView *waitAlertView = [[WaitAlertView alloc] init];
        [waitAlertView show];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [waitAlertView hide];
            [self performSegueWithIdentifier:@"ReplacePassworldVC" sender:self];
        });
    }else{
        AlertView *alertView = [[AlertView alloc] initWithTitle:@"请输入邮箱"];
        
        [alertView show];
    }
    
}
#pragma mark -- private
- (BOOL)judgeEmailTextFeildIsValid:(UITextField *)textField{
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:textField.text];
    
}
- (BOOL)judgePhoneTextFeildIsValid:(UITextField *)textField{
    
    NSString *phoneRegex = @"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    return [phoneTest evaluateWithObject:textField.text];
}
- (IBAction)unwindToMainViewController:(UIStoryboardSegue *)unwindSegue{
    
}

@end
